//
//  SleepChartView.m
//  JunZeWristband
//
//  Created by Kendama on 2017/9/22.
//  Copyright © 2017年 DT. All rights reserved.
//

#import "SleepChartView.h"
#import "WeekAxisValueFormatter.h"

@implementation SleepChartView

- (void)updateChartData
{
//    if (self.shouldHideData)
//    {
//        _chartView.data = nil;
//        return;
//    }
    
//    [self setDataCount:7 range:1];
}

- (void)setDataCount:(int)count range:(double)range
{
    float groupSpace = 0.2f;
    float barSpace = 0.03f;
    float barWidth = 0.25f;
    // (0.2 + 0.03) * 4 + 0.08 = 1.00 -> interval per "group"
    
    NSMutableArray *yVals1 = [[NSMutableArray alloc] init];
    NSMutableArray *yVals2 = [[NSMutableArray alloc] init];
    NSMutableArray *yVals3 = [[NSMutableArray alloc] init];
    
    double randomMultiplier = range * 100.f;
    
//    int groupCount = count + 1;
//    int startYear = 1980;
//    int endYear = startYear + groupCount;
    
    for (int i = 0; i < count; i++)
    {
        [yVals1 addObject:[[BarChartDataEntry alloc]
                           initWithX:i
                           y:(double) (arc4random_uniform(randomMultiplier))]];
        
        [yVals2 addObject:[[BarChartDataEntry alloc]
                           initWithX:i
                           y:(double) (arc4random_uniform(randomMultiplier))]];
        
        [yVals3 addObject:[[BarChartDataEntry alloc]
                           initWithX:i
                           y:(double) (arc4random_uniform(randomMultiplier))]];
        

    }
    
    BarChartDataSet *set1 = nil, *set2 = nil, *set3 = nil;
    if (_chartView.data.dataSetCount > 0)
    {
        set1 = (BarChartDataSet *)_chartView.data.dataSets[0];
        set2 = (BarChartDataSet *)_chartView.data.dataSets[1];
        set3 = (BarChartDataSet *)_chartView.data.dataSets[2];
        set1.values = yVals1;
        set2.values = yVals2;
        set3.values = yVals3;
        
//        BarChartData *data = _chartView.barData;
        
//        _chartView.xAxis.axisMinimum = startYear;
//        _chartView.xAxis.axisMaximum = [data groupWidthWithGroupSpace:groupSpace barSpace: barSpace] * _sliderX.value + startYear;
//        [data groupBarsFromX: startYear groupSpace: groupSpace barSpace: barSpace];
        
        [_chartView.data notifyDataChanged];
        [_chartView notifyDataSetChanged];
    }
    else
    {
        set1 = [[BarChartDataSet alloc] initWithValues:yVals1 label:@"Company A"];
        [set1 setColor:[UIColor colorWithRed:104/255.f green:241/255.f blue:175/255.f alpha:1.f]];
        set1.drawValuesEnabled = NO;
        
        set2 = [[BarChartDataSet alloc] initWithValues:yVals2 label:@"Company B"];
        [set2 setColor:[UIColor colorWithRed:164/255.f green:228/255.f blue:251/255.f alpha:1.f]];
        set2.drawValuesEnabled = NO;

        set3 = [[BarChartDataSet alloc] initWithValues:yVals3 label:@"Company C"];
        [set3 setColor:[UIColor colorWithRed:242/255.f green:247/255.f blue:158/255.f alpha:1.f]];
        set3.drawValuesEnabled = NO;

        NSMutableArray *dataSets = [[NSMutableArray alloc] init];
        [dataSets addObject:set1];
        [dataSets addObject:set2];
        [dataSets addObject:set3];
        
        BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets];
        [data setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:10.f]];
//        [data setValueFormatter:[[LargeValueFormatter alloc] init]];
        
        // specify the width each bar should have
        data.barWidth = barWidth;
        
        // restrict the x-axis range
//        _chartView.xAxis.axisMinimum = startYear;
//        // groupWidthWithGroupSpace(...) is a helper that calculates the width each group needs based on the provided parameters
//        _chartView.xAxis.axisMaximum = startYear + [data groupWidthWithGroupSpace:groupSpace barSpace: barSpace] * groupCount;
        
        [data groupBarsFromX:0.1 groupSpace:groupSpace barSpace: 0];
        
        ChartXAxis *xAxis = _chartView.xAxis;
        xAxis.axisLineWidth = 1;//设置X轴线宽
        xAxis.labelPosition = XAxisLabelPositionBottom;//X轴的显示位置，默认是显示在上面的
        xAxis.drawGridLinesEnabled = NO;//不绘制网格线
        xAxis.axisMinimum = 0;
        xAxis.spaceMax = 1;
        xAxis.valueFormatter = [[WeekAxisValueFormatter alloc] initForChart:_chartView];
        xAxis.labelCount = 7;
        xAxis.centerAxisLabelsEnabled = YES;
        _chartView.data = data;
    }
}

- (void)setWeekData:(NSArray *)data
{
    NSArray *deepSleepArray = data.firstObject;
    NSArray *lightSleepArray = data.lastObject;
    float groupSpace = 0.2f;
    float barSpace = 0.03f;
    float barWidth = 0.25f;
    // (0.2 + 0.03) * 4 + 0.08 = 1.00 -> interval per "group"
    
    NSMutableArray *yVals1 = [[NSMutableArray alloc] init];
    NSMutableArray *yVals2 = [[NSMutableArray alloc] init];
    NSMutableArray *yVals3 = [[NSMutableArray alloc] init];
    
    //    double randomMultiplier = range * 100.f;
    
    //    int groupCount = count + 1;
    //    int startYear = 1980;
    //    int endYear = startYear + groupCount;
    NSInteger count = deepSleepArray.count;
    if (deepSleepArray.count == lightSleepArray.count)
    {
        count = deepSleepArray.count;
    }
    
    for (int i = 0; i < count; i++)
    {
        [yVals1 addObject:[[BarChartDataEntry alloc]
                           initWithX:i
                           y:[deepSleepArray[i] floatValue] + [lightSleepArray[i] floatValue]]];
        
        [yVals2 addObject:[[BarChartDataEntry alloc]
                           initWithX:i
                           y:[deepSleepArray[i] floatValue]]];
        
        [yVals3 addObject:[[BarChartDataEntry alloc]
                           initWithX:i
                           y:[lightSleepArray[i] floatValue]]];
        
        
    }
    
    BarChartDataSet *set1 = nil, *set2 = nil, *set3 = nil;
//    if (_chartView.data.dataSetCount > 0)
//    {
//        set1 = (BarChartDataSet *)_chartView.data.dataSets[0];
//        set2 = (BarChartDataSet *)_chartView.data.dataSets[1];
//        set3 = (BarChartDataSet *)_chartView.data.dataSets[2];
//        set1.values = yVals1;
//        set2.values = yVals2;
//        set3.values = yVals3;
//        
//        //        BarChartData *data = _chartView.barData;
//        
//        //        _chartView.xAxis.axisMinimum = startYear;
//        //        _chartView.xAxis.axisMaximum = [data groupWidthWithGroupSpace:groupSpace barSpace: barSpace] * _sliderX.value + startYear;
//        //        [data groupBarsFromX: startYear groupSpace: groupSpace barSpace: barSpace];
//        
//        [_chartView.data notifyDataChanged];
//        [_chartView notifyDataSetChanged];
//    }
//    else
//    {
        set1 = [[BarChartDataSet alloc] initWithValues:yVals1 label:@"Company A"];
        [set1 setColor:[UIColor colorWithRed:239/255.f green:114/255.f blue:114/255.f alpha:1.f]];
        set1.drawValuesEnabled = NO;
        
        set2 = [[BarChartDataSet alloc] initWithValues:yVals2 label:@"Company B"];
        [set2 setColor:[UIColor colorWithRed:254/255.f green:144/255.f blue:144/255.f alpha:1.f]];
        set2.drawValuesEnabled = NO;
        
        set3 = [[BarChartDataSet alloc] initWithValues:yVals3 label:@"Company C"];
        [set3 setColor:[UIColor colorWithRed:255/255.f green:191/255.f blue:191/255.f alpha:1.f]];
        set3.drawValuesEnabled = NO;
        
        NSMutableArray *dataSets = [[NSMutableArray alloc] init];
        [dataSets addObject:set1];
        [dataSets addObject:set2];
        [dataSets addObject:set3];
        
        BarChartData *barChartdata = [[BarChartData alloc] initWithDataSets:dataSets];
        [barChartdata setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:10.f]];
        //        [data setValueFormatter:[[LargeValueFormatter alloc] init]];
        
        // specify the width each bar should have
        barChartdata.barWidth = barWidth;
        
        // restrict the x-axis range
        //        _chartView.xAxis.axisMinimum = startYear;
        //        // groupWidthWithGroupSpace(...) is a helper that calculates the width each group needs based on the provided parameters
        //        _chartView.xAxis.axisMaximum = startYear + [data groupWidthWithGroupSpace:groupSpace barSpace: barSpace] * groupCount;
        
        [barChartdata groupBarsFromX:0.1 groupSpace:groupSpace barSpace: 0];
        
        ChartXAxis *xAxis = _chartView.xAxis;
        xAxis.axisLineWidth = 1;//设置X轴线宽
        xAxis.labelPosition = XAxisLabelPositionBottom;//X轴的显示位置，默认是显示在上面的
        xAxis.drawGridLinesEnabled = NO;//不绘制网格线
        xAxis.axisMinimum = 0;
        xAxis.spaceMax = 1;
        xAxis.valueFormatter = [[WeekAxisValueFormatter alloc] initForChart:_chartView];
        xAxis.labelCount = 7;
        xAxis.centerAxisLabelsEnabled = YES;
        _chartView.data = barChartdata;
//    }
}
- (void)setData:(NSArray *)data
{
    double start = 0;
    
    NSMutableArray *xVals = [[NSMutableArray alloc] init];
    NSInteger count;
    if ([data.firstObject count] == [data.lastObject count])
    {
        count = [data.firstObject count];
    }
    for (int i = 0; i < count; i++) {
        [xVals addObject:[NSString stringWithFormat:@"%d", i+1]];
    }
    
    ChartXAxis *xAxis = _chartView.xAxis;
    xAxis.axisLineWidth = 1;//设置X轴线宽
    xAxis.labelPosition = XAxisLabelPositionBottom;//X轴的显示位置，默认是显示在上面的
    xAxis.drawGridLinesEnabled = NO;//不绘制网格线
    xAxis.axisMinimum = 0;
//    if (data.count == 8)
//    {
//        xAxis.spaceMax = 1;
//        xAxis.labelCount = 7;
//        xAxis.valueFormatter = [[DayAxisValueFormatter alloc] initForChart:_chartView];
//    }
//    else if (data.count > 8)
//    {
        xAxis.spaceMax = 4;
        xAxis.spaceMin = 1;
        xAxis.valueFormatter = nil;
        xAxis.labelCount = 10;
//    }
    
    NSMutableArray *yVals = [[NSMutableArray alloc] init];
    
    for (int i = start; i < count; i++)
    {
        [yVals addObject:[[BarChartDataEntry alloc] initWithX:i y:[data.firstObject[i] floatValue]+[data.lastObject[i] floatValue]]];
    }
    
    BarChartDataSet *set1 = nil;
//    if (_chartView.data.dataSetCount > 0)
//    {
//        set1 = (BarChartDataSet *)_chartView.data.dataSets[0];
//        set1.values = yVals;
//        [_chartView.data notifyDataChanged];
//        [_chartView notifyDataSetChanged];
//    }
//    else
//    {
        set1 = [[BarChartDataSet alloc] initWithValues:yVals label:@""];
        [set1 setColors:@[colorWithAlpha(248, 165, 165, 1)]];
        set1.drawIconsEnabled = NO;
        set1.drawValuesEnabled = NO;//是否在柱形图上面显示数值
        
        NSMutableArray *dataSets = [[NSMutableArray alloc] init];
        [dataSets addObject:set1];
        
        BarChartData *barChartData = [[BarChartData alloc] initWithDataSets:dataSets];
        //        BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets];
        [barChartData setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:10.f]];
        
        barChartData.barWidth = 0.9f;
        
        _chartView.data = barChartData;
//    }
}


- (BarChartView *)chartView
{
    if(!_chartView)
    {
        UIView *superView = self;
        _chartView = [[BarChartView alloc]init];
        [superView addSubview:_chartView];
        //        _chartView.backgroundColor = [UIColor colorWithRed:230/255.0f green:253/255.0f blue:253/255.0f alpha:1];
        _chartView.noDataText = MyNSLocalizedString(@"暂无数据");//没有数据时的文字提示
        _chartView.drawValueAboveBarEnabled = YES;//数值显示在柱形的上面还是下面
        ////        _chartView.drawHighlightArrowEnabled = NO;//点击柱形图是否显示箭头
        //        _chartView.drawBarShadowEnabled = NO;//是否绘制柱形的阴影背景
        //        _chartView.scaleYEnabled = NO;//取消Y轴缩放
        //        _chartView.doubleTapToZoomEnabled = NO;//取消双击缩放
        //        _chartView.dragEnabled = YES;//启用拖拽图表
        //        _chartView.dragDecelerationEnabled = YES;//拖拽后是否有惯性效果
        //        _chartView.dragDecelerationFrictionCoef = 0.9;//拖拽后惯性效果的摩擦系数(0~1)
        //
        //        ChartXAxis *xAxis = _chartView.xAxis;
        //        xAxis.axisLineWidth = 1;//设置X轴线宽
        //        xAxis.labelPosition = XAxisLabelPositionBottom;//X轴的显示位置，默认是显示在上面的
        //        xAxis.drawGridLinesEnabled = NO;//不绘制网格线
        ////        xAxis.spaceBetweenLabels = 4;//设置label间隔，若设置为1，则如果能全部显示，则每个柱形下面都会显示label
        //        xAxis.labelTextColor = [UIColor brownColor];//label文字颜色
        //
        //        _chartView.rightAxis.enabled = NO;//不绘制右边轴
        _chartView.legend.enabled = NO;
        _chartView.descriptionText = @"";
        _chartView.scaleYEnabled = NO;//取消Y轴缩放
        _chartView.scaleXEnabled = NO;//取消Y轴缩放
        _chartView.doubleTapToZoomEnabled = NO;//取消双击缩放
        
        //        ChartXAxis *xAxis = _chartView.xAxis;
        //        xAxis.labelPosition = XAxisLabelPositionBottom;
        //        xAxis.labelFont = [UIFont systemFontOfSize:10.f];
        //        xAxis.drawGridLinesEnabled = NO;
        //        xAxis.granularity = 1.0; // only intervals of 1 day
        //        xAxis.labelCount = 7;
        ////        xAxis.spaceMin = 1;
        //        xAxis.spaceMax = 4;
        //        xAxis.valueFormatter = [[DayAxisValueFormatter alloc] initForChart:_chartView];
        
        NSNumberFormatter *leftAxisFormatter = [[NSNumberFormatter alloc] init];
        leftAxisFormatter.minimumFractionDigits = 0;
        leftAxisFormatter.maximumFractionDigits = 10;
        //        leftAxisFormatter.negativeSuffix = @" $";
        //        leftAxisFormatter.positiveSuffix = @" $";
        
        ChartYAxis *leftAxis = _chartView.leftAxis;
        leftAxis.labelFont = [UIFont systemFontOfSize:10.f];
        leftAxis.labelCount = 8;
        leftAxis.valueFormatter = [[ChartDefaultAxisValueFormatter alloc] initWithFormatter:leftAxisFormatter];
        leftAxis.labelPosition = YAxisLabelPositionOutsideChart;
        leftAxis.spaceTop = 0.15;
        leftAxis.axisMinimum = 0; // this replaces startAtZero = YES
        
        ChartYAxis *rightAxis = _chartView.rightAxis;
        rightAxis.enabled = NO;
        rightAxis.drawGridLinesEnabled = NO;
        rightAxis.labelFont = [UIFont systemFontOfSize:10.f];
        rightAxis.labelCount = 8;
        rightAxis.valueFormatter = leftAxis.valueFormatter;
//        rightAxis.spaceTop = 0.15;
//        rightAxis.axisMinimum = 0.0; // this replaces startAtZero = YES
        
        ChartLegend *l = _chartView.legend;
        l.horizontalAlignment = ChartLegendHorizontalAlignmentLeft;
        l.verticalAlignment = ChartLegendVerticalAlignmentBottom;
        l.orientation = ChartLegendOrientationHorizontal;
        l.drawInside = NO;
        l.form = ChartLegendFormSquare;
        l.formSize = 9.0;
        l.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:11.f];
        l.xEntrySpace = 4.0;
        
        //        XYMarkerView *marker = [[XYMarkerView alloc]
        //                                initWithColor: [UIColor colorWithWhite:180/255. alpha:1.0]
        //                                font: [UIFont systemFontOfSize:12.0]
        //                                textColor: UIColor.whiteColor
        //                                insets: UIEdgeInsetsMake(8.0, 8.0, 20.0, 8.0)
        //                                xAxisValueFormatter: _chartView.xAxis.valueFormatter];
        //        marker.chartView = _chartView;
        //        marker.minimumSize = CGSizeMake(80.f, 40.f);
        //        _chartView.marker = marker;
        
        
    }
    return _chartView;
}


- (UISegmentedControl *)segmentedControl
{
    if(!_segmentedControl)
    {
        UIView *superView = self;
        NSArray *segmentedArray = @[MyNSLocalizedString(@"周"),MyNSLocalizedString(@"月")];
        _segmentedControl = [[UISegmentedControl alloc] initWithItems:segmentedArray];
        _segmentedControl.selectedSegmentIndex = 0;
        _segmentedControl.tintColor = [UIColor colorWithHexString:@"F06161"];
        [_segmentedControl setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]} forState:UIControlStateSelected];
        [_segmentedControl setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"F06161"]} forState:UIControlStateNormal];
        [superView addSubview:_segmentedControl];
        [superView addSubview:_segmentedControl];
        //        _segmentedControl
    }
    return _segmentedControl;
}
- (UIButton *)leftButton
{
    if(!_leftButton)
    {
        UIView *superView = self;
        _leftButton = [[UIButton alloc]init];
        [superView addSubview:_leftButton];
        [_leftButton setImage:imageWithName(@"left_btn") forState:UIControlStateNormal];
        _leftButton.contentMode = UIViewContentModeCenter;

    }
    return _leftButton;
}
- (UIButton *)rightButton
{
    if(!_rightButton)
    {
        UIView *superView = self;
        _rightButton = [[UIButton alloc]init];
        [superView addSubview:_rightButton];
        [_rightButton setImage:imageWithName(@"right_btn") forState:UIControlStateNormal];
        _rightButton.contentMode = UIViewContentModeCenter;

    }
    return _rightButton;
}
- (UILabel *)dateLabel
{
    if(!_dateLabel)
    {
        UIView *superView = self;
        _dateLabel = [[UILabel alloc]init];
        [superView addSubview:_dateLabel];
        [_dateLabel setFont:fontWithSize(15)];
        [_dateLabel setTextColor:[UIColor darkGrayColor]];
        _dateLabel.textAlignment = NSTextAlignmentCenter;
        //        _dateLabel.text = <#text#>;
    }
    return _dateLabel;
}
- (UILabel *)radiateLabel
{
    if(!_radiateLabel)
    {
        UIView *superView = self.bottomView;
        _radiateLabel = [[UILabel alloc]init];
        [superView addSubview:_radiateLabel];
        //        [_radiateLabel setFont:fontWithSize(15)];
        [_radiateLabel setTextColor:[UIColor colorWithHexString:@"F06161"]];
        _radiateLabel.textAlignment = NSTextAlignmentCenter;
        //        _radiateLabel.text = <#text#>;
    }
    return _radiateLabel;
}
- (UILabel *)unitLabel
{
    if(!_unitLabel)
    {
        UIView *superView = self.bottomView;
        _unitLabel = [[UILabel alloc]init];
        [superView addSubview:_unitLabel];
        [_unitLabel setFont:fontWithSize(15)];
        [_unitLabel setTextColor:[UIColor darkGrayColor]];
        _unitLabel.textAlignment = NSTextAlignmentCenter;
        //        _unitLabel.text = <#text#>;
    }
    return _unitLabel;
}

- (UIView *)bottomView
{
    if(!_bottomView)
    {
        UIView *superView = self;
        _bottomView = [[UIView alloc]init];
        [superView addSubview:_bottomView];
        _bottomView.backgroundColor = [UIColor colorWithHexString:@"FBFBFB"];
    }
    return _bottomView;
}
- (SleepLabelView *)countView
{
    if(!_countView)
    {
        UIView *superView = self.bottomView;
        _countView = [[SleepLabelView alloc]init];
        [superView addSubview:_countView];
        _countView.dataLabel.textColor = [UIColor colorWithHexString:@"F06161"];
        _countView.iconView.image = imageWithName(@"count_sleep_icon");
        _countView.unitLabel.text = MyNSLocalizedString(@"总睡眠");
    }
    return _countView;
}
- (SleepLabelView *)deepView
{
    if(!_deepView)
    {
        UIView *superView = self.bottomView;
        _deepView = [[SleepLabelView alloc]init];
        [superView addSubview:_deepView];
        _deepView.dataLabel.textColor = [UIColor colorWithRed:254/255.f green:144/255.f blue:144/255.f alpha:1.f];
        _deepView.iconView.image = imageWithName(@"deep_sleep_icon");
        _deepView.unitLabel.text = MyNSLocalizedString(@"深睡眠");

    }
    return _deepView;
}
- (SleepLabelView *)lightView
{
    if(!_lightView)
    {
        UIView *superView = self.bottomView;
        _lightView = [[SleepLabelView alloc]init];
        [superView addSubview:_lightView];
        _lightView.dataLabel.textColor = [UIColor colorWithRed:255/255.f green:191/255.f blue:191/255.f alpha:1.f];
        _lightView.iconView.image = imageWithName(@"light_sleep_icon");
        _lightView.unitLabel.text = MyNSLocalizedString(@"浅睡眠");

    }
    return _lightView;
}


- (void)masLayoutSubview
{
    __weak UIView *superView = self;
    [self.segmentedControl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_top).with.offset(px1920Height(82));
        make.centerX.mas_equalTo(superView.mas_centerX);
        make.width.mas_equalTo(px1080Width(350));
    }];
    
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(superView.mas_centerX);
        make.top.mas_equalTo(self.segmentedControl.mas_bottom).with.offset(px1920Height(100));
    }];
    
    [self.leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.dateLabel.mas_centerY);
        make.right.mas_equalTo(self.dateLabel.mas_left);
        make.height.width.mas_equalTo(px1920Height(130));
    }];
    
    [self.rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.dateLabel.mas_centerY);
        make.left.mas_equalTo(self.dateLabel.mas_right);
        make.height.width.mas_equalTo(px1920Height(130));
    }];
    
    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(superView);
        make.bottom.mas_equalTo(superView.mas_bottom).with.offset(px1920Height(-42));
        make.height.mas_equalTo(px1920Height(293));
    }];
    
//    [self.radiateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.mas_equalTo(self.bottomView.mas_centerX);
//        make.bottom.mas_equalTo(self.bottomView.mas_centerY).with.offset(px1920Height(-25));
//    }];
//    
//    [self.unitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.mas_equalTo(self.bottomView.mas_centerX);
//        make.top.mas_equalTo(self.bottomView.mas_centerY).with.offset(px1920Height(25));
//    }];
    [self.countView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(superView.mas_left).with.offset(SCREEN_WIDTH*1/6);
        make.top.mas_equalTo(self.bottomView).with.offset(px1920Height(50));
    }];
    
    [self.deepView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(superView.mas_left).with.offset(SCREEN_WIDTH*3/6);
        make.top.mas_equalTo(self.bottomView).with.offset(px1920Height(50));
    }];
    
    [self.lightView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(superView.mas_left).with.offset(SCREEN_WIDTH*5/6);
        make.top.mas_equalTo(self.bottomView).with.offset(px1920Height(50));
    }];
    
    [self.chartView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.dateLabel.mas_bottom).with.offset(px1920Height(74));
        make.left.mas_equalTo(superView.mas_left).with.offset(px1080Width(25));
        make.right.mas_equalTo(superView.mas_right).with.offset(px1080Width(-25));
        make.bottom.mas_equalTo(self.bottomView.mas_top).with.offset(px1920Height(-100));
        
    }];
    
//    self.dateLabel.text = @"4月2日-4月9日";
    
//    self.radiateLabel.text = @"7000mT";
//    self.unitLabel.text = @"周辐射值";
//    self.countView.dataLabel.text = @"2时1分";
//    self.deepView.dataLabel.text = @"2时1分";
//    self.lightView.dataLabel.text = @"2时1分";

    [self updateChartData];
}

@end
